package com.tuju.currency.view

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.tencent.mm.opensdk.modelmsg.SendAuth
import com.tuju.currency.R
import kotlinx.android.synthetic.main.activity_login.*
import com.tencent.mm.opensdk.openapi.IWXAPI
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import com.tuju.currency.Constants

class LoginActivity : AppCompatActivity() {

    private lateinit var api: IWXAPI

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)
        api = WXAPIFactory.createWXAPI(this, Constants.APP_ID, true)
        //将应用的appid注册到微信
        api.registerApp(Constants.APP_ID)

        btn_login.setOnClickListener {
            val req = SendAuth.Req()
            req.scope = "snsapi_userinfo"
            req.state = "online_doctor"
            api.sendReq(req)

            finish()
        }
    }

    companion object {
        @JvmStatic
        fun start(context: Context) {
            context.startActivity(Intent(context, LoginActivity::class.java))
        }
    }


}
